'use strict';

const Controller = require('egg').Controller;

class CommonController extends Controller {
    async upload() {
        let { ctx, app, config } = this;
        const stream = await ctx.getFileStream();
        let data =await ctx.service.common.upload(stream);
        if(data.code === 1){
            ctx.body = config.sendJson({
                data: data.url
            });
        }else{
            ctx.body = config.sendJson({
                code: config.code.MESSAGE,
                message: '上传失败'
            });
        }

    }
}

module.exports = CommonController;
